package GUIs;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import javax.swing.JButton;

/**
 *
 * @author Tinacho
 */
public class GUI_Configuracion extends javax.swing.JFrame {


    public GUI_Configuracion() {
        initComponents();
        centrarJFrame();
    }

    
    // ---------------------------------------------------------
    // ------- Seccion de metodos publicos : Getters
    // ---------------------------------------------------------
    
    /**
     * 
     * @return el valor corriente de la variable 'jText_Nombre'
     */ 
    public String obtenerJTF_Nombre(){
        return this.jText_Nombre.getText();
    }// Fin obtenerJTF_Nombre
    
    /**
     * 
     * @return el valor corriente de la variable 'jText_Direccion'
     */ 
    public String obtenerJTF_Direccion(){
        return this.jText_Direccion.getText();
    }// Fin obtenerJTF_Direccion

    /**
     * 
     * @return el valor corriente de la variable 'jText_Ciudad'
     */ 
    public String obtenerJTF_Ciudad(){
        return this.jText_Ciudad.getText();
    }// Fin obtenerJTF_Ciudad
    
    /**
     * 
     * @return el valor corriente de la variable 'jText_Telefono'
     */ 
    public String obtenerJTF_Telefono(){
        return this.jText_Telefono.getText();
    }// Fin obtenerJTF_Telefono    
    
    /**
     * 
     * @return el valor corriente de la variable 'jbutton_Guardar'
     */ 
    public JButton obtenerJB_Guardar(){
        return this.jbutton_Guardar;
    }// Fin obtenerJB_Guardar    

    
    public void rellenarJTF_Nombre(String nombreP){
        this.jText_Nombre.setText(nombreP);
    }
    
    public void rellenarJTF_Ciudad(String ciudadP){
        this.jText_Ciudad.setText(ciudadP);
    }
    
    public void rellenarJTF_Direccion(String direccionP){
        this.jText_Direccion.setText(direccionP);
    }
    
    public void rellenarJTF_Telefono(String telefonoP){
        this.jText_Telefono.setText(telefonoP);
    }    
    
    
    /**
     * @brief Muestra mensaje de error cuando no se completaron los campos obligatorios.
     */
    public void mostrarMensajeDeErrorCampoVacio(){
        this.jL_Error.setText("El campo obligatorio (*) no debe permanecer vacío.");
    }// Fin mostrarMensajeDeError
    
    
    /**
     * @brief Muestra mensaje de error de SQL.
     */
    public void mostrarMensajeDeErrorSQL(){
        this.jL_Error.setText("Se ha producido un error en la consulta con la base de datos.");
    }// Fin mostrarMensajeDeError
    
    
    /**
     * @brief Muestra mensaje de error de IO.
     */
    public void mostrarMensajeDeErrorIO(){
        this.jL_Error.setText("Se ha producido un error de entrada/salida.");
    }// Fin mostrarMensajeDeError    
    
    /**
     * Metodo encargado de asociar los eventos correspondientes a 
     * los diferentes componentes de la interfaz
     * 
     * @param lis
     */
    public void setActionListeners(ActionListener lis) {
        this.jbutton_Guardar.addActionListener(lis);   
    }// Fin setActionListeners    
    
    
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        label_Nombre = new javax.swing.JLabel();
        label_Direccion = new javax.swing.JLabel();
        label_Ciudad = new javax.swing.JLabel();
        label_Telefono = new javax.swing.JLabel();
        label_titulo = new javax.swing.JLabel();
        jText_Nombre = new javax.swing.JTextField();
        jText_Direccion = new javax.swing.JTextField();
        jText_Ciudad = new javax.swing.JTextField();
        jText_Telefono = new javax.swing.JTextField();
        jbutton_Guardar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jL_Error = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Configuración de pista");
        setAlwaysOnTop(true);

        label_Nombre.setFont(new java.awt.Font("Andalus", 2, 14)); // NOI18N
        label_Nombre.setText("Nombre (*)");

        label_Direccion.setFont(new java.awt.Font("Andalus", 2, 14)); // NOI18N
        label_Direccion.setText("Dirección");

        label_Ciudad.setFont(new java.awt.Font("Andalus", 2, 14)); // NOI18N
        label_Ciudad.setText("Ciudad");

        label_Telefono.setFont(new java.awt.Font("Andalus", 2, 14)); // NOI18N
        label_Telefono.setText("Telefono");

        label_titulo.setFont(new java.awt.Font("Andalus", 0, 18)); // NOI18N
        label_titulo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        label_titulo.setText("Por favor, introduzca la información correspondiente a la pista");

        jbutton_Guardar.setText("Guardar Información");
        jbutton_Guardar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        jLabel1.setText("(*) Campo obligatorio");

        jL_Error.setFont(new java.awt.Font("Century Schoolbook", 1, 14)); // NOI18N
        jL_Error.setForeground(new java.awt.Color(255, 51, 51));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jL_Error, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(label_titulo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(label_Nombre, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(label_Direccion, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)
                            .addComponent(label_Ciudad, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(label_Telefono, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jText_Nombre)
                            .addComponent(jText_Direccion, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jText_Ciudad)
                            .addComponent(jText_Telefono))
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 202, Short.MAX_VALUE)
                        .addComponent(jbutton_Guardar)
                        .addGap(202, 202, 202))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(label_titulo)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_Nombre)
                    .addComponent(jText_Nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_Direccion)
                    .addComponent(jText_Direccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_Ciudad)
                    .addComponent(jText_Ciudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label_Telefono)
                    .addComponent(jText_Telefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                .addComponent(jL_Error, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jbutton_Guardar)
                .addGap(13, 13, 13))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(GUI_Configuracion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GUI_Configuracion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GUI_Configuracion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GUI_Configuracion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new GUI_Configuracion().setVisible(true);
            }
        });
    }

    
    private void centrarJFrame(){
        Dimension pantalla = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frame =this.getSize();
        this.setLocation((pantalla.width-frame.width)/2, (pantalla.height-frame.height)/2);
    }
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jL_Error;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTextField jText_Ciudad;
    private javax.swing.JTextField jText_Direccion;
    private javax.swing.JTextField jText_Nombre;
    private javax.swing.JTextField jText_Telefono;
    private javax.swing.JButton jbutton_Guardar;
    private javax.swing.JLabel label_Ciudad;
    private javax.swing.JLabel label_Direccion;
    private javax.swing.JLabel label_Nombre;
    private javax.swing.JLabel label_Telefono;
    private javax.swing.JLabel label_titulo;
    // End of variables declaration//GEN-END:variables
}
